<?php
class LoginController extends Zend_Controller_Action
{
public function indexAction()
	{
		$form = new Zend_Form();
		$db = Zend_Registry::get('db');
		if($form->isValid($_POST)){
			$userName = Zend_Controller_Request_Http::getPost('username');
			$password = Zend_Controller_Request_Http::getPost('password');
						//performing authentication
			$authAdapter = new Zend_Auth_Adapter_DbTable($db);
			$authAdapter
					   ->setTableName('users')
					   ->setIdentityColumn('user')
					   ->setCredentialColumn('password');
			$authAdapter
					   ->setIdentity($userName)
					   ->setCredential($password);
		    $result = $authAdapter->authenticate();
		
		if(!$result->isValid())
		{
			
			return $this->_redirect('index');
		}    
		if(!$this->getRequest()->isPost()) {
		//return $this->_forward('index');
		throw new Exception('cannot found');
		}
		//return $this->_forward('takeorder');
	//	$this->view->form = $this->addCategory();
	//	echo $this->render('addcategory');	
		}
	/*if(!$this->getRequest()->isPost()) {
		return $this->_forward('index');
		}*/
	}
	
	
}
?>